using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMContractController
    {
        private clsConnect cls = new clsConnect();

        #region[Get-Data]
        public DataTable BindGirdTMContract()
        {
            return cls.BindGridData("sp_TMContract");
        }
        public DataTable BindGirdTMContract_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMContract_Detail_Edit", "@Contract_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMContract(clsTMContractProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Contrac_Alias", data.Contrac_Alias);
            cls.AddParameter("@Type_Of_Contract_ID", data.Type_Of_Contract_ID);
            cls.AddParameter("@Customers_ID", data.Customers_ID);
            cls.AddParameter("@Vehicle_ID", data.Vehicle_ID);
            cls.AddParameter("@Member_ID", data.Member_ID);
            cls.AddParameter("@Contract_Signed_Date", data.Contract_Signed_Date);
            cls.AddParameter("@Contract_Expires_Date", data.Contract_Expires_Date);
            cls.AddParameter("@Contract_Payment", data.Contract_Payment);
            cls.AddParameter("@Contract_Promotions", data.Contract_Promotions);
            cls.AddParameter("@Contract_Content", data.Contract_Content);
            cls.AddParameter("@Contract_Note", data.Contract_Note);
            cls.ExecuteNonQuery("sp_TMContract_Insert");
            return true;
        }
        public bool UpdateTMContract(clsTMContractProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Contract_ID", data.Contract_ID);
            cls.AddParameter("@Contrac_Alias", data.Contrac_Alias);
            cls.AddParameter("@Type_Of_Contract_ID", data.Type_Of_Contract_ID);
            cls.AddParameter("@Customers_ID", data.Customers_ID);
            cls.AddParameter("@Vehicle_ID", data.Vehicle_ID);
            cls.AddParameter("@Member_ID", data.Member_ID);
            cls.AddParameter("@Contract_Signed_Date", data.Contract_Signed_Date);
            cls.AddParameter("@Contract_Expires_Date", data.Contract_Expires_Date);
            cls.AddParameter("@Contract_Payment", data.Contract_Payment);
            cls.AddParameter("@Contract_Promotions", data.Contract_Promotions);
            cls.AddParameter("@Contract_Content", data.Contract_Content);
            cls.AddParameter("@Contract_Note", data.Contract_Note);
            cls.ExecuteNonQuery("sp_TMContract_Update");
            return true;
        }
        public bool DeleteTMContract(int id)
        {
            cls.Delete("sp_TMContract_Delete", "@Contract_ID", id);
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywrods)
        {
            return cls.Search("sp_TMContract_Search", "@KEYWORDS", keywrods);
        }
        public DataTable TMContract_Fillter_Date(string DateBegin, string EndBegin)
        {
            return cls.FillterDay("sp_TMContract_Fillter_Date", DateBegin, EndBegin);
        }
        #endregion
    }
}